import request from './request.js'
import { Decrypt } from '@/utils/aes.js'

// 添加收藏
export function addFavorite({courseId,token}){
    return request({
        url:'/api/favorite/addFavorite',
        method:'POST',
        data:{courseId},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}

// 删除收藏
export function deleteFavorite({memberId,courseId,token}){
    return request({
        url:'/api/favorite/deleteFavorite',
        method:'get',
        params:{memberId,courseId},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}

// 获取收藏
export function getFavoriteList({pageSize,pageNum,token,entity}){
    return request({
        url:'/api/favorite/getByMemberId',
        method:'POST',
        data:{pageSize,pageNum,entity},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}